package com.lagou.cl.controller;

import com.lagou.cl.controller.vo.LoginRespVo;
import com.lagou.cl.pojo.UserInfo;
import com.lagou.cl.util.BaseSession;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 程  林
 * @date 2020-04-18 19:11
 * @description //
 * @since V1.0.0
 */
@RestController
@RequestMapping("/v1/account")
public class UserController extends BaseSession {


	@RequestMapping(value = "login", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = RequestMethod.POST)
	public LoginRespVo login(@RequestBody UserInfo account) {
		System.out.println("登录~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
		LoginRespVo result = new LoginRespVo();
		boolean isLogin = false;
		if ("admin".equals(account.getUserName()) && "admin".equals(account.getPassword())) {
			isLogin = true;

			//将用户session中
			this.setAccount(account);
		}

		result.setLogin(isLogin);

		return result;
	}
}
